const filmAndCinemasDao = require('../dao/filmAndCinemasDao');

module.exports.findAll = async function (searchObj) {
    return await filmAndCinemasDao.findAll(searchObj);
}

module.exports.findByDate = async function (date, filmId, cinemaId) {
    return await filmAndCinemasDao.findByDate(date, filmId, cinemaId);
}

module.exports.find = async function (searchObj, page) {
    return await filmAndCinemasDao.find(searchObj, page);
}

module.exports.findById = async function (id) {
    try {
        return await filmAndCinemasDao.findById(id);
    } catch (err) {
        return {}
    }
}

module.exports.insert = async function (filmAndCinemas) {
    return await filmAndCinemasDao.insert(filmAndCinemas);
}

module.exports.update = async function (id, filmAndCinemas) {
    try {
        return await filmAndCinemasDao.update(id, filmAndCinemas);
    } catch (err) {
        return {}
    }
}

// update schedule
module.exports.updateSchedule = async function (id, oldScheduleJSON, newScheduleJSON) {
    return await filmAndCinemasDao.updateSchedule(id, oldScheduleJSON, newScheduleJSON);
}

module.exports.delete = async function (id) {
    return await filmAndCinemasDao.delete(id);
}